<?php require_once('include/header1.php'); ?>
<?php
    if (!function_exists("GetSQLValueString")) {
        function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
            $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

            $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

            switch ($theType) {
                case "text":
                    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                    break;
                case "long":
                case "int":
                    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
                    break;
                case "double":
                    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
                    break;
                case "date":
                    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                    break;
                case "defined":
                    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
                    break;
            }
            return $theValue;
        }
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
        $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
        $insertSQL = sprintf("INSERT INTO stream (stream_id, stream) VALUES (%s, %s)",
                GetSQLValueString($_POST['hiddenField'], "int"),
                GetSQLValueString($_POST['textfield'], "text"));


        $Result1 = mysql_query($insertSQL) or die(mysql_error());
    }


    $query_strea = "SELECT * FROM stream";
    $strea = mysql_query($query_strea) or die(mysql_error());
    $row_strea = mysql_fetch_assoc($strea);
    $totalRows_strea = mysql_num_rows($strea);
?>
<?php require_once('include/sidebar.php'); ?>
<div id="admin_full_inner_body">
    <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#33CCFF">
        <tr>

            <td width="621" valign="top" ><p align="center" class="title"><br>
                    Add Stram </p>
                <form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
                    <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>Add Stram : </td>
                            <td><label for="textfield"></label>
                                <input type="text" name="textfield" id="textfield">
                                <input type="hidden" name="hiddenField"> <span class="formfield">First name should be in Capital </span></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td><label for="Submit"></label>
                                <input type="submit" name="Submit" value="Add Stream" id="Submit"></td>
                        </tr>
                    </table>
                    <input type="hidden" name="MM_insert" value="form1">
                </form>
                <p align="center" class="title">Check Stram! :
                    <label for="select"></label>
                    <select name="select" id="select">
<?php
                            do {
                            ?>
                        <option value="<?php echo $row_strea['stream_id']?>"><?php echo $row_strea['stream']?></option>
    <?php
                            } while ($row_strea = mysql_fetch_assoc($strea));
                            $rows = mysql_num_rows($strea);
                            if($rows > 0) {
                                mysql_data_seek($strea, 0);
                                $row_strea = mysql_fetch_assoc($strea);
                            }
                        ?>
                    </select>
                </p>
            </td>
        </tr>
    </table>

</div>


<?php require_once('include/footer.php'); ?>
